//
//  UPCalendarDayCell.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/26.
//

#import "UPCalendarDayCell.h"
#import <Masonry/Masonry.h>

@interface UPCalendarDayCell ()

@property (nonatomic, strong) UILabel *dayLabel;

@end

@implementation UPCalendarDayCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.dayLabel];
        
        [self.dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)configureWithDay:(NSInteger)day isSelected:(BOOL)isSelected {
    self.dayLabel.text = [NSString stringWithFormat:@"%ld", (long)day];
    self.dayLabel.textColor = isSelected ? [UIColor colorWithHexString:@"#000000"] : [UIColor colorWithHexString:@"#999999"];
    self.contentView.backgroundColor = isSelected ? [[UIColor colorWithHexString:@"#42714A"] colorWithAlphaComponent:0.1] : UIColor.clearColor;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius = 15.0;
}

- (UILabel *)dayLabel {
    if (!_dayLabel) {
        _dayLabel = [[UILabel alloc] init];
        _dayLabel.textAlignment = NSTextAlignmentCenter;
        _dayLabel.font = [UIFont systemFontOfSize:16];
    }
    return _dayLabel;
}

@end
